<template>
  <div>
    <p>3. 新增图书信息</p>
    <div>
      <input type="text" placeholder="书名" v-model="bookObj.bookname" />
    </div>
    <div>
      <input type="text" placeholder="作者" v-model="bookObj.author" />
    </div>
    <div>
      <input type="text" placeholder="出版社" v-model="bookObj.publisher" />
    </div>
    <button @click="sendFn">发布</button>
  </div>
</template>

<script>
import axios from "axios";
export default {
  data() {
    return {
      bookObj: {
        // 参数名提前和后台的参数名对上-发送请求就不用再次对接了
        bookname: "",
        author: "",
        publisher: "",
      },
    };
  },
  methods: {
    sendFn() {
      axios({
        url: "http://123.57.109.30:3006/api/addbook",
        method: "post",
        data: {
          appkey: "7250d3eb-18e1-41bc-8bb2-11483665535a",
          // bookname:this.bookObj.bookname,
          // author:this.bookObj.author,
          // publisher:this.bookObj.publisher,
          ...this.bookObj,
        },
      }).then((res) => {
        console.log(res);
      });
    },
  },
};
</script>

<style>
</style>